package com.fly;

import org.apache.commons.lang3.SystemUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.data.map.repository.config.EnableMapRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;

import com.fly.core.utils.SpringContextUtils;
import com.fly.show.git.GitService;

@EnableCaching
@EnableScheduling
@EnableMapRepositories
@SpringBootApplication
public class BootApplication
{
    @Autowired
    GitService gitService;
    
    public static void main(String[] args)
    {
        SpringApplication.run(BootApplication.class, args);
    }
    
    @Bean
    CommandLineRunner init()
    {
        return args -> {
            gitService.init();
            if (SystemUtils.IS_OS_WINDOWS)// 防止非windows系统报错，启动失败
            {
                Runtime.getRuntime().exec("cmd /c start " + SpringContextUtils.getServerBaseURL());
            }
        };
    }
}
